//
//  TitleView.m
//  Bread-Live
//
//  Created by ios on 2017/3/14.
//  Copyright © 2017年 Chris. All rights reserved.
//

#import "TitleView.h"

@implementation TitleView

+(TitleView *)initWithTitle:(NSString *)title{
    TitleView *titleView = [[TitleView alloc] initWithFrame:CGRectMake(0, 0, kWidth, 40)];
    
    titleView.backgroundColor = [UIColor whiteColor];
    
    UIView *leftImageView = [[UIView alloc] initWithFrame:CGRectMake(10, 11, 18, 18)];
    
    CGFloat  leftImageViewW = leftImageView.frame.size.width;
    CGFloat  leftImageViewH = leftImageView.frame.size.height;
    
    UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0,leftImageViewW,leftImageViewH) byRoundingCorners:UIRectCornerTopRight | UIRectCornerTopLeft cornerRadii:CGSizeMake(5, 0)];
    CAShapeLayer *layer = [CAShapeLayer layer];
    layer.bounds        = CGRectMake(0, 0, leftImageViewW, leftImageViewH);
    layer.position      = CGPointMake(leftImageViewW/2, leftImageViewH/2);
    layer.strokeColor   = WYCOLOR(249, 203, 101, 1.0).CGColor;
    layer.lineWidth     = 1.5;
    layer.fillColor     = WYCOLOR(255, 237, 167, 1.0).CGColor;
    layer.path          = path.CGPath;
    
    [leftImageView.layer addSublayer:layer];
    
    [titleView addSubview:leftImageView];
    
    UILabel *label  = [[UILabel alloc] initWithFrame:CGRectMake(35, 9.5, 200, 21)];
    label.textColor = WYCOLOR(140, 140, 140, 1.0);
    label.font      = [UIFont wyNormalFot:17];
    label.text      = title;
    
    [titleView addSubview:label];
    
    return titleView;
}



/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
